package com.example.publish_model;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.viewbinding.ViewBinding;

import com.alibaba.android.arouter.launcher.ARouter;
import com.example.common.mvvm.view.BaseFragment;
import com.example.common.providerservice.CheckLoginAPI;
import com.example.publish_model.databinding.FragmentPublishBinding;
import com.example.publish_model.pushorpull.PullActivity;
import com.example.publish_model.pushorpull.PushActivity;

import java.util.Map;

public class PublishFragment extends BaseFragment<FragmentPublishBinding,PublishVIewModel> {

    private CheckLoginAPI checkLoginAPI;
    private Button startLive;
    private Button watchLive;

    @Override
    public void receiveData(Map<String, Object> data) {

    }

    @Override
    public View bindLayout() {
        return v.getRoot();
    }

    @Override
    public ViewBinding initBind() {
        return FragmentPublishBinding.inflate(inflater);
    }

    @Override
    public void initView() {
        checkLoginAPI = (CheckLoginAPI) ARouter.getInstance().build("/user/checklogin").navigation();
        if (!checkLoginAPI.checkLogin())
            ARouter.getInstance().build("/user/LoginActivity").navigation();
        startLive = v.startLive;
        watchLive = v.watchLive;
    }

    @Override
    public void initData() {
        startLive.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), PushActivity.class);
                startActivity(intent);
            }
        });

        watchLive.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), PullActivity.class);
                startActivity(intent);
            }
        });
    }
}
